<script>
  init({
    title: 'Custom Toolbar',
    desc: 'Use `toolbar` option to define the custom toolbars.',
    links: ['bootstrap-table.min.css'],
    scripts: ['bootstrap-table.min.js']
  })
</script>

<div id="toolbar">
  <div class="form-inline" role="form">
    <div class="form-group">
      <span>Offset: </span>
      <input name="offset" class="form-control w70" type="number" value="0">
    </div>
    <div class="form-group">
      <span>Limit: </span>
      <input name="limit" class="form-control w70" type="number" value="5">
    </div>
    <div class="form-group">
      <input name="search" class="form-control" type="text" placeholder="Search">
    </div>
    <button id="ok" type="submit" class="btn btn-primary">OK</button>
  </div>
</div>
<table
  id="table"
  data-toggle="table"
  data-height="460"
  data-toolbar="#toolbar"
  data-show-refresh="true"
  data-show-toggle="true"
  data-show-columns="true"
  data-query-params="queryParams"
  data-response-handler="responseHandler"
  data-url="https://examples.wenzhixin.net.cn/examples/bootstrap_table/data">
  <thead>
    <tr>
      <th data-field="id">ID</th>
      <th data-field="name">Item Name</th>
      <th data-field="price">Item Price</th>
    </tr>
  </thead>
</table>

<script>
  var $table = $('#table')
  var $ok = $('#ok')

  function mounted() {
    $ok.click(function () {
      $table.bootstrapTable('refresh')
    })
  }

  function queryParams() {
    var params = {}
    $('#toolbar').find('input[name]').each(function () {
      params[$(this).attr('name')] = $(this).val()
    })
    return params
  }

  function responseHandler(res) {
    return res.rows
  }
</script>
